package org.zhxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.StringUtils;
import org.zhxy.model.entity.Clazz;
import org.zhxy.service.ClazzService;
import org.zhxy.mapper.ClazzMapper;
import org.springframework.stereotype.Service;

/**
 * @author walter
 * @description 针对表【tb_clazz】的数据库操作Service实现
 * @createDate 2025-07-02 07:40:34
 */
@Service
public class ClazzServiceImpl extends ServiceImpl<ClazzMapper, Clazz> implements ClazzService {

    // 分页条件查询班级信息
    @Override
    public IPage<Clazz> page(IPage<Clazz> page, Clazz clazz) {
        if (clazz == null) {
            return page(page);
        }

        LambdaQueryWrapper<Clazz> wrapper = new LambdaQueryWrapper<>();
        String gradeName = clazz.getGradeName();
        wrapper.eq(StringUtils.hasText(gradeName), Clazz::getGradeName, gradeName);
        String name = clazz.getName();
        wrapper.like(StringUtils.hasText(name), Clazz::getName, name);

        return page(page, wrapper);
    }
}




